  function [v,s,perc,sim]=igone2lognorm(mu,sd,lb,ub,ndr);
% function [v,s,perc,sim]=see_igone( mu , sd , lb , ub , nd );
% See IG1 with mean = MU 
% and for the time being infinite variance 
% lb  (optional) lower bound of the graph (default = 0.01)  
% ub  (optional) upper bound of the graph (default = 5 )
% ndr (optional) number of draws ( default = 20000 ) 
% V=2 can change that from loc_gone.m 
% Alejandro Justiniano
% Last Modified December 7 2006 
% ========================================================
pvec=[0.005 0.01 0.05 0.1 0.5 0.9 0.95 0.99 0.995]; 
if nargin < 5 
    ndr=100000; 
    if nargin < 4 
        ub=8;
        if nargin < 3 
            lb=0.0001; 
        end
    end
end
if sd > 40 
    sd=inf 
end 
npoints=10000; 
[ss,vv]=inverse_gamma_specification(mu,sd,1); 
gr=linspace(lb,ub,npoints);
pd=zeros(npoints,1);
ii=1;
for ii=1:npoints; 
    pd(ii)=pdf_igone(gr(ii),vv,ss) ;
end
mod=( (vv/(vv+1))^0.5 )*sqrt(ss/vv);
var_ln=log(1+(sd*sd)/(mu*mu)); 
% Transform to lognormal 
mu_ln=log(mu)-0.5*var_ln; 
sd_ln=sqrt(var_ln); 
dispaj('MU LN: ',mu_ln); 
dispaj('SD LN: ',sd_ln); 
dispaj('VAR LN: ',sd_ln*sd_ln); 


pd_ln=zeros(npoints,1); 
cdf_ln=zeros(npoints,1); 
ii=1; 
for ii=1:npoints; 
    pd_ln(ii)=lognpdf(gr(ii),mu_ln,sd_ln); 
    cdf_ln(ii)=logncdf(gr(ii),mu_ln,sd_ln); 
end 

figure; 
plot(gr(:),pd(:)); 
hold; 
plot(gr(:),pd_ln(:),'r:','LineWidth',2);
legend('IG1','LogN'); 

figure; 
plot( log(gr(:)),pd_ln(:) ); 
vline(mu_ln); 



% temp=cumsum(pd(:)); 
% cdf_aprox=temp/(temp(end)); 
% clear temp; 
% subplot(2,1,2); 
% plot(gr(:),cdf_aprox(:)); 
% hold; 
% 
% 
% legend('IG1','LogN'); 
% plot(gr(:),cdf_ln(:),'r:','LineWidth',2);
% legend('IG1','LogN'); 
% 
% rat=pd./pd_ln; 
% figure; 
% plot( gr(:), rat ); 
% 
% 
% cut=find( gr > 4 );
% tail=gr(cut); 
% 
% plot( cdf_aprox(tail), cdf_ln(tail) ); 

%temp=cumsum(pd_ln); 
%cdfln_aprox=temp/(tempsum(end)); 
%plot(gr(:),cdfln_aprox); 
%hold; 
%plot(gr(:),cdf_ln(:),'r:','LineWidth',2);

disp('Done'); 





